package comm

import (
	"errors"
	"fmt"
	"goconf"
)

type ConfObjectSt struct {
	ConfSys struct {
		A string
	}

	ConfComm struct {
		SubServer string
		PubServer string
	}

	ConfLog struct {
		Conf string
	}
}

func ParseConf(confile string) (*ConfObjectSt, error) {

	conf, err := goconf.New(confile)
	if err != nil {
		fmt.Println("import conf file:", confile, " error[", err, "]")
		return nil, errors.New("import conf file error!")
	}

	confobj := new(ConfObjectSt)

	conf.Get("/sys", &confobj.ConfSys)
	conf.Get("/comm", &confobj.ConfComm)
	conf.Get("/log", &confobj.ConfLog)

	return confobj, nil
}
